package com.example.springbootwebrestfulcrud.controller;

import com.example.springbootwebrestfulcrud.exception.UserNotFoundRxception;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @Auther: luzhanshi
 * @Date: 2021/1/30 - 01 - 30 - 10:24 
 * @Description: com.example.springbootwebrestfulcrud.controller
 * @version: 1.0
 */
@Controller
public class HelloController {
//    @RequestMapping({"/","/index.html"})
//    public String index(){
//        return "index";
//    }


    @ResponseBody
    @RequestMapping("/hello")
    public String hello() {
        return "hello world";
    }


    @RequestMapping("/sucess")
    public String sucess(Map<String, Object> map) {
        map.put("hello", "你好");
        return "sucess";
    }


    @GetMapping("/hello2")
    public String hello2(@RequestParam("user") String user) {
        if ("aaa".equals(user)) {
            throw new UserNotFoundRxception();
        }
        return "sucess";
    }


}
